﻿<!doctype html>
 <html >
 <head>
   <meta charset="UTF-8">
   <link rel="stylesheet" href="../../../css/common.css">
   <link rel="stylesheet" href="../../../css/main.css">
   <script type="text/javascript" src="../../../js/jquery.min.js"></script>
   <script type="text/javascript" src="../../../js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="../../../js/common.js"></script>
     <script type="text/javascript" src="/layer/layer.js"></script>

     <script>


         $(function () {
             /*1、异步校验菜单名称是否可用*/
             $("[name='menuName']").blur(function () {
                 var menuName=$("[name='menuName']").val();
                 if (menuName==""){
                     //小tips
                     layer.tips('菜单名不能为空', '#menuName', {
                         tips: [1, '#FD482C'],
                         time: 4000
                     });
                     $("[type='submit']").attr("disabled", "disabled");
                 }else {
                     $.ajax({
                         url: "/resource/system/menu/ajaxName",
                         data: {"menuName": menuName},
                         type: "post",
                         dataType: "json",
                         success: function (re) {
                             if (re > 0) {
                                 /*$("[name='menuName']").next().html("<font color='red'>菜单名已存在,请重新命名!</font>");*/
                                 layer.tips('菜单名已存在', '#menuName', {
                                     tips: [1, '#FD482C'],
                                     time: 4000
                                 });
                                 $("[type='submit']").attr("disabled", "disabled");

                             } else {
                                 layer.tips('菜单名可用', '#menuName', {
                                     tips: [1, 'green'],
                                     time: 1000
                                 });
                                 $("[name='menuName']").next().html("");
                                 $("[type='submit']").removeAttr("disabled")
                             }
                         }
                     })
                 }
             });


             /*2、异步校验URL是否可用  menuUrl*/
             $("[name='menuUrl']").blur(function () {
                 var menuUrl=$("[name='menuUrl']").val();
                 if (menuUrl==""){
                     //小tips
                     layer.tips('请求路径不能为空', '#menuUrl', {
                         tips: [1, '#FD482C'],
                         time: 4000
                     });
                     $("[type='submit']").attr("disabled", "disabled");
                 }else {
                     $.ajax({
                         url: "/resource/system/menu/ajaxUrl",
                         data: {"menuUrl": menuUrl},
                         type: "post",
                         dataType: "json",
                         success: function (re) {
                             if (re > 0) {
                                 /*$("[name='menuName']").next().html("<font color='red'>菜单名已存在,请重新命名!</font>");*/
                                 layer.tips('请求路径已存在', '#menuUrl', {
                                     tips: [1, '#FD482C'],
                                     time: 4000
                                 });
                                 $("[type='submit']").attr("disabled", "disabled");

                             } else {
                                 layer.tips('请求路径可用', '#menuUrl', {
                                     tips: [1, 'green'],
                                     time: 1000
                                 });
                                 $("[type='submit']").removeAttr("disabled")
                             }
                         }
                     })
                 }
             });

             /*3、异步校验权限码是否可用  menuUrl*/
             $("[name='preCode']").blur(function () {
                 var preCode=$("[name='preCode']").val();
                 if (preCode==""){
                     //小tips
                     layer.tips('权限码不能为空', '#preCode', {
                         tips: [1, '#FD482C'],
                         time: 4000
                     });
                     $("[type='submit']").attr("disabled", "disabled");
                 }else {
                     $.ajax({
                         url: "/resource/system/menu/ajaxPreCode",
                         data: {"preCode": preCode},
                         type: "post",
                         dataType: "json",
                         success: function (re) {
                             if (re > 0) {
                                 /*$("[name='menuName']").next().html("<font color='red'>菜单名已存在,请重新命名!</font>");*/
                                 layer.tips('权限码已存在', '#preCode', {
                                     tips: [1, '#FD482C'],
                                     time: 4000
                                 });
                                 $("[type='submit']").attr("disabled", "disabled");

                             } else {
                                 layer.tips('权限码可用', '#preCode', {
                                     tips: [1, 'green'],
                                     time: 1000
                                 });
                                 $("[type='submit']").removeAttr("disabled")
                             }
                         }
                     })
                 }
             });


         })
     </script>
</head>

<body>
  <div id="forms" class="mt10">
        <div class="box">
          <div class="box_border">
            <div class="box_top"><b class="pl15">添加菜单</b></div>
            <div class="box_center">
              <form action="/resource/system/menu/addMenu" method="post" class="jqtransform">
               <table class="form_table pt15 pb15" width="100%" border="0" cellpadding="0" cellspacing="0">
                 <tr>
                  <td class="td_right">菜单名称：</td>
                  <td class=""> 
                    <input type="text" name="menuName" required id="menuName" class="input-text lh30" size="40"/><span></span>
                  </td>
				  </tr>
                <tr >
                  <td class="td_right">父级菜单：</td>
                  <td class="">
 
                    <span class="fl">
                      <div class="select_border"> 
                        <div class="select_containers "> 
                        <select name="superMenuId" class="select">
                            <option value="0">顶级菜单</option>
                            <#list menu as m>
                                <option value="${m.menuId}">${m.menuName}</option>
                            </#list>
                        </select> 
                        </div> 
                      </div> 
                    </span>
                  </td>
                 </tr>

				 <tr>
                  <td class="td_right">路径：</td>
				  <td><input type="" name="menuUrl" id="menuUrl" required class="input-text lh30" size="40"/></td>
                </tr>
                 <tr>
                  <td class="td_right">状态：</td>
                  <td class="">
                    <input type="radio" name="menuStatus" checked  value="0"/> 启用
                    <input type="radio" name="menuStatus" value="1"/> 冻结
                  </td>
                 </tr>
                   <tr>
                       <td class="td_right">菜单类型：</td>
                       <td class="">
                           <input type="radio" name="type" value="menu"  checked/> 菜单
                           <input type="radio" name="type" value="pression"/> 功能
                       </td>
                   </tr>
                   <tr>
                       <td class="td_right">权限码：</td>
                       <td class="">
                           <input type="text" id="preCode" name="preCode" class="input-text lh30" />
                       </td>
                   </tr>
                   <tr>
                 <tr>
                   <td class="td_right">&nbsp;</td>
                   <td class="">
                     <input type="submit" name="button" class="btn btn82 btn_save2" value="保存"> 
                    <input type="button" name="button" class="btn btn82 btn_res" onclick="location.href='javascript:history.go(-1)'" value="返回"> 
                   </td>
                 </tr>
               </table>
               </form>
            </div>
          </div>
        </div>
     </div>
   </div> 
</body>

</html>